package ar.com.pasae.usuarios;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import ar.com.pasae.avisos.AvisoInmobiliario;

@Entity(name = "Usuario")
@Table(name = "Usuario")

public class Usuario {

	@Id
	@Column(name="id", length=10)
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	@Column(name = "mail", length = 50)
	private String mail;
	@Column(name = "userName", length = 50, nullable = false)
	private String userName;
	@Column(name = "password", length = 50, nullable = false)
	private String password;
	@Column(name = "domicillio", length = 50)
	private String domicillio;
	@Column(name = "nombre", length = 50, nullable = false)
	private String nombre;
	@Column(name = "telefono", length = 50)
	private String telefono;

	@OneToMany(mappedBy="usuario", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private Collection<AvisoInmobiliario> avisos;

	
//	private RolUsuario rol;
	
/*
 * Constructors	
 */
	public Usuario() {}
	
	public Usuario(String mail, String userName, String password, String domicillio, String nombre, String telefono, RolUsuario rol){
		this.setDomicillio(domicillio);
		this.setMail(mail);
		this.setNombre(nombre);
		this.setPassword(password);
		this.setTelefono(telefono);
		this.setUserName(userName);
//		this.setAvisos(new ArrayList<AvisoInmobiliario>());
//		this.setRol(rol);
		
	}
	
	
/*
 * Setters y Getters
 */
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getDomicillio() {
		return domicillio;
	}
	public void setDomicillio(String domicillio) {
		this.domicillio = domicillio;
	}
	public String getNombre() {
		return nombre;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}
	public String getTelefono() {
		return telefono;
	}
	public void setTelefono(String telefono) {
		this.telefono = telefono;
	}
	
	public Collection<AvisoInmobiliario> getAvisos() {
		return avisos;
	}
	public void setAvisos(Collection<AvisoInmobiliario> avisos) {
		this.avisos = avisos;
	}
	/*
	public RolUsuario getRol() {
		return rol;
	}

	public void setRol(RolUsuario rol) {
		this.rol = rol;
	}*/

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	
	
	
}
